package com.mzkj.wanjulaile.mobile.api.modules.account.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mzkj.common.utils.DateUtils;
import com.mzkj.wanjulaile.mobile.api.common.entity.DataEntity;
import com.mzkj.wanjulaile.mobile.api.modules.account.constant.Constant;
import com.mzkj.wanjulaile.mobile.api.modules.coupon.entity.AccountCoupon;
import com.mzkj.wanjulaile.mobile.api.modules.user.entity.User;

import java.util.Date;

/**
 * 购买vip记录Entity
 *
 * @author ianly
 * @version 2016-10-17
 */
public class BuyVip extends DataEntity<BuyVip> {

    private static final long serialVersionUID = 1L;

    public static final Integer PAYSTATUS_NOT_PAID = 0; //未付款

    public static final Integer PAYSTATUS_PAID = 1; //已付款

    public static final Integer PAYSTATUS_PAYING = 2; //付款中

    /**押金退款状态**/
    public static final Integer DEPOSIT_STATUS = 0 ;    //默认(押金未退)
    public static final Integer DEPOSIT_STATUS_RETURNED = 1;  //押金 已退款
    public static final Integer DEPOSIT_STATUS_REFUNDING = 2; //押金 退款中
    public static final Integer DEPOSIT_STATUS_PROCESSING = 3; //押金 申请退款
    public static final Integer DEPOSIT_STATUS_CANCEL = 4;  //押金 后台撤销申请

    private String payNumber;       //支付编号
    private Account account;        //会员信息
    private VipScheme vipScheme;    //购买的vip
    private Integer payStatus;      //支付状态
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date activeTime;        //激活时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date deadTime;          //失效时间
    private Integer active;         //是否激活,0-未激活 1-已激活 2-已过期
    private Integer fee;            //vip费用
    private Integer deposit;        //vip押金
    private Integer refundStatus;   //是否已退押金 0否(默认) 1是
    private int couponVal;//优惠券金额
    private AccountCoupon accountCoupon;  //会员优惠券
    private User user;              //推荐人(扫谁的二维码来购买vip)
    private Integer status; //是否使用了 0:否(默认) 1:是

    private Date applyDate;	//申请退押金时间
    private String batchNo;		//退款批次号
    // TODO 后期会有扣部分押金功能
    private Integer realDeposit;    //剩余押金金额 后期
    private String firstFlag;   //是否第一次购买

    /**
     * 查询条件
     */
    private String startDate;
    private String endDate;


    public BuyVip() {
        super();
    }

    public BuyVip(String id) {
        super(id);
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    public VipScheme getVipScheme() {
        return vipScheme;
    }

    public void setVipScheme(VipScheme vipScheme) {
        this.vipScheme = vipScheme;
    }

    public String getStartDate() {
        return startDate;
    }

    public void setStartDate(String startDate) {
        this.startDate = startDate;
    }

    public String getEndDate() {
        return endDate;
    }

    public void setEndDate(String endDate) {
        this.endDate = endDate;
    }

    public String getPayNumber() {
        return payNumber;
    }

    public void setPayNumber(String payNumber) {
        this.payNumber = payNumber;
    }

    public Integer getPayStatus() {
        return payStatus;
    }

    public void setPayStatus(Integer payStatus) {
        this.payStatus = payStatus;
    }

    public Date getActiveTime() {
        return activeTime;
    }

    public void setActiveTime(Date activeTime) {
        if (vipScheme != null && vipScheme.getType() != null) {
            int vipType = vipScheme.getType();
            // 设置失效时间
            if (vipType == Constant.YEAR_VIP) {
                //年度会员
                this.deadTime = DateUtils.addYears(activeTime, 1);
            } else if (vipType == Constant.QUARTER_VIP) {
                //季度会员
                this.deadTime = DateUtils.addMonths(activeTime, 3);
            } else if (vipType == Constant.MONTH_VIP) {
                //月度会员
                this.deadTime = DateUtils.addMonths(activeTime, 1);
            } else if (vipType == Constant.TEMP_VIP) {
                //体验会员
                this.deadTime = DateUtils.addDays(activeTime, 7);
            }else if (vipType == Constant.HALF_YEAR_VIP){
                //半年会员
                this.deadTime = DateUtils.addMonths(activeTime,6);
            }
        }
        this.activeTime = activeTime;
    }

    public Date getDeadTime() {
        return deadTime;
    }

    public void setDeadTime(Date deadTime) {
        this.deadTime = deadTime;
    }

    public Integer getActive() {
        return active;
    }

    public void setActive(Integer active) {
        this.active = active;
    }

    public Integer getFee() {
        return fee;
    }

    public void setFee(Integer fee) {
        this.fee = fee;
    }

    public Integer getDeposit() {
        return deposit;
    }

    public void setDeposit(Integer deposit) {
        this.deposit = deposit;
    }

    public Integer getRefundStatus() {
        return refundStatus;
    }

    public void setRefundStatus(Integer refundStatus) {
        this.refundStatus = refundStatus;
    }

    public int getCouponVal() {
        return couponVal;
    }

    public void setCouponVal(int couponVal) {
        this.couponVal = couponVal;
    }

    public AccountCoupon getAccountCoupon() {
        return accountCoupon;
    }

    public void setAccountCoupon(AccountCoupon accountCoupon) {
        this.accountCoupon = accountCoupon;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getApplyDate() {
        return applyDate;
    }

    public void setApplyDate(Date applyDate) {
        this.applyDate = applyDate;
    }

    public String getBatchNo() {
        return batchNo;
    }

    public void setBatchNo(String batchNo) {
        this.batchNo = batchNo;
    }

    public Integer getRealDeposit() {
        return realDeposit;
    }

    public void setRealDeposit(Integer realDeposit) {
        this.realDeposit = realDeposit;
    }

    public String getFirstFlag() {
        return firstFlag;
    }

    public void setFirstFlag(String firstFlag) {
        this.firstFlag = firstFlag;
    }
}